package com.pubinfo.passbook.engine.process.variable.medicine.payinformation;

import com.pubinfo.passbook.common.model.ruler.PayInformation;
import com.pubinfo.passbook.common.service.ruler.InformationService;
import com.pubinfo.passbook.common.utils.ApplicationContextUilts;
import lombok.extern.slf4j.Slf4j;

import java.math.BigDecimal;

/**
 * 获取诊查费
 *
 * @author zhouch
 * @date 2022/3/14 9:17
 */
@Slf4j
public class ByCostNameProcessor extends PayinformationVariableProcessor {

    InformationService informationService;

    public ByCostNameProcessor() {
        informationService = ApplicationContextUilts.getBean(InformationService.class);
    }

    @Override
    public BigDecimal get(PayInformation data) {
        BigDecimal indagation = informationService.getAmountByCostName(data.getEInvoiceId());
        if (indagation.equals(new BigDecimal(-0.0000999))) {
            cache.markNeedAudit();
            log.info("{} ==> 需要人工审核.", getClass().getName());
            indagation = BigDecimal.ZERO;
        }

        return indagation;
    }

}
